<template>
	<view class="qiandao-page">
		<view class="weui-page__back">
			<image src="https://img.2024csnl.com/static/2.x/a107.png" mode="widthFix"></image>
		</view>
		<view class="qiandao-thead" v-if="false">
			<view class="rows">
				<text>今日奖励总量：</text>
				<text>{{today_total}}个</text>
			</view>
			<view class="rows">
				<text>剩余可领取总量：</text>
				<text>{{today_total_ok}}个</text>
			</view>
		</view>

		<view class="qiandao-title">
			<image src="/assets/qiandao/qiandao-2.png" mode="aspectFit">
			</image>
			<text>每日签到，泌豆拿到手软！</text>
		</view>

		<view class="qiandao-circle">
			<view class="back">
				<image src="https://img.2024csnl.com/static/2.x/a106.png" mode=""></image>
			</view>
			<view class="front">
				<view class="tip">
					<text>您已成功签到</text>
				</view>
				<view class="num">
					<text class="strong">{{signtimeslx}}</text>
					<text>天</text>
				</view>
			</view>
		</view>

		<view class="qiandao-gxz">
			<view class="text" v-if="false">
				<text>恭喜您获得泌豆</text>
				<text>{{sign_total}}个</text>
			</view>
			<view class="btn" @click="handleQiandao">
				<button v-if="hassign == 1" class="is-disabled">今日已签到</button>
				<button v-else>立即签到</button>
				<image class="icon" v-if="hassign == 0" src="https://img.2024csnl.com/static/2.x/a108.png" mode="aspectFit"></image>
			</view>
		</view>

		<view class="qiandao-rule" v-if="false">
			<view class="tit">
				<text>签到规则：</text>
			</view>
			<view class="rich" v-html="sign_guize">
			</view>
		</view>
	</view>
</template>


<script>
	import {
		merchantScoreDetails
	} from "../../api/index.js"
	export default {
		data() {
			return {
				info: {},
				today_total: 0,
				today_total_ok: 0,
				signtimeslx: 0,
				sign_total: 0,
				sign_guize: '',
				hassign: 0,
			}
		},
		onLoad() {

			this.getMerchantScoreDetails()
		},
		methods: {

			async getMerchantScoreDetails() {
				const res = await merchantScoreDetails('s=/ApiSign/index', {})
				const {
					msg,
					today_total,
					today_total_ok,
					signtimeslx,
					sign_total,
					sign_guize,
					hassign,
					status,
				} = res.data
				console.log(res, "res")
				if (status == 1) {
					this.today_total = today_total;
					this.today_total_ok = today_total_ok;
					this.signtimeslx = signtimeslx;
					this.sign_total = sign_total;
					this.sign_guize = sign_guize;
					this.hassign = hassign

				} else {
					this.showToast(msg)
				}
			},
			async handleQiandao() {
				if (this.hassign == 1) return false
				const res = await merchantScoreDetails('s=/ApiSign/signin', {})
				const {
					msg,
					status,
				} = res.data
				console.log(res, "res")
				this.showToast(msg)

				setTimeout(async () => {
					await this.getMerchantScoreDetails()
				}, 1000)

			},
		}
	}
</script>

<style lang="less" scoped>
	.qiandao-page {
		min-height: 100vh;
		background: #fff;
		background-size: 100% 100%;
	}

	.qiandao-thead {
		display: flex;
		position: relative;

		.rows {
			flex: 1;
			padding: 30rpx;

			text {
				display: block;
				line-height: 1.3;
				font-size: 36rpx;
				text-align: center;
				color: #ffffff;
			}
		}
	}

	.qiandao-title {
		position: relative;
		text-align: center;
		margin: 0rpx 0rpx 0rpx 0rpx;

		image {
			display: block;
			width: 100vw;
			height: 10vw;
			margin: 0 auto -20rpx;
		}

		text {
			font-size: 35rpx;
			color: #ffffff;
		}
	}

	.qiandao-circle {
		position: relative;
		width: 80vw;
		height: 80vw;
		background-size: cover;
		box-sizing: border-box;
		padding: 20vw 0 0;
		margin: 40px auto auto auto;
		text-align: center;
		.back {
			position: absolute;
			left: 0;
			right: 0;
			top: 0;
			bottom: 0;
			z-index: 0;
			image {
				display: block;
				width: 100%;
				height: 100%;
			}
		}
		.front {
			position: relative;
			z-index: 1;
		}
		.tip {
			line-height: 60rpx;
			font-size: 35rpx;
			color: #000;
			text {}
		}

		.num {
			line-height: 160rpx;
			color: #000;

			text {
				font-size: 40rpx;
				vertical-align: baseline;

				&.strong {
					font-weight: bold;
					font-size: 100rpx;
				}
			}
		}
	}

	.qiandao-gxz {
		position: relative;
		text-align: center;
		margin: 100rpx 15vw 10vw;
		.text {
			margin: 0 0 10vw;
			line-height: 1.5;
			font-size: 35rpx;
			color: #ffffff;

			text {
				display: block;
			}
		}

		.btn {
			position: relative;
			button {
				height: 90rpx;
				line-height: 90rpx;
				border-radius: 90rpx;
				background: #41644A;
				color: #fff;
				font-size: 35rpx;
				border: 0;
				&.is-disabled {
					background: fade(#41644A, 30%) !important;
				}
			}
			
			.icon {
				position: absolute;
				right: 10%;
				top: 50%;
				width: 100rpx;
				height: 80rpx;
				animation: click 1s ease infinite;
			}
		}
	}

	.qiandao-rule {
		padding: 5vw 10vw 30vw;
		color: #333;

		.tit {
			margin-bottom: 20rpx;
			font-size: 35rpx;
		}

		.rich {
			line-height: 1.5;
			font-size: 30rpx;

			text {
				&.red {
					color: #ff0000;
					font-style: italic;
				}
			}
		}
	}
	
	@-webkit-keyframes click {
		0% {
			transform: translate(20px, 20px);
		}
		100% {
			transform: translate(0, 0);
		}
	}
</style>